home *** CD-ROM | disk | FTP | other *** search
/ Sky at Night 2007 June / SAN CD 6-2007 CD-ROM 25.iso / pc / Software / AstroGrav_Win / Java / jre1.6.0 / lib / rt.jar / javax / imageio / IIOParam.class (.txt) < prev    next >
Encoding:
Java Class File  |  2006-11-29  |  3.2 KB  |  157 lines

  1. package javax.imageio;
  2.  
  3. import java.awt.Point;
  4. import java.awt.Rectangle;
  5.  
  6. public abstract class IIOParam {
  7.    protected Rectangle sourceRegion = null;
  8.    protected int sourceXSubsampling = 1;
  9.    protected int sourceYSubsampling = 1;
  10.    protected int subsamplingXOffset = 0;
  11.    protected int subsamplingYOffset = 0;
  12.    protected int[] sourceBands = null;
  13.    protected ImageTypeSpecifier destinationType = null;
  14.    protected Point destinationOffset = new Point(0, 0);
  15.    protected IIOParamController defaultController = null;
  16.    protected IIOParamController controller = null;
  17.  
  18.    protected IIOParam() {
  19.       this.controller = this.defaultController;
  20.    }
  21.  
  22.    public void setSourceRegion(Rectangle var1) {
  23.       if (var1 == null) {
  24.          this.sourceRegion = null;
  25.       } else if (var1.x < 0) {
  26.          throw new IllegalArgumentException("sourceRegion.x < 0!");
  27.       } else if (var1.y < 0) {
  28.          throw new IllegalArgumentException("sourceRegion.y < 0!");
  29.       } else if (var1.width <= 0) {
  30.          throw new IllegalArgumentException("sourceRegion.width <= 0!");
  31.       } else if (var1.height <= 0) {
  32.          throw new IllegalArgumentException("sourceRegion.height <= 0!");
  33.       } else if (var1.width <= this.subsamplingXOffset) {
  34.          throw new IllegalStateException("sourceRegion.width <= subsamplingXOffset!");
  35.       } else if (var1.height <= this.subsamplingYOffset) {
  36.          throw new IllegalStateException("sourceRegion.height <= subsamplingYOffset!");
  37.       } else {
  38.          this.sourceRegion = (Rectangle)var1.clone();
  39.       }
  40.    }
  41.  
  42.    public Rectangle getSourceRegion() {
  43.       return this.sourceRegion == null ? null : (Rectangle)this.sourceRegion.clone();
  44.    }
  45.  
  46.    public void setSourceSubsampling(int var1, int var2, int var3, int var4) {
  47.       if (var1 <= 0) {
  48.          throw new IllegalArgumentException("sourceXSubsampling <= 0!");
  49.       } else if (var2 <= 0) {
  50.          throw new IllegalArgumentException("sourceYSubsampling <= 0!");
  51.       } else if (var3 >= 0 && var3 < var1) {
  52.          if (var4 >= 0 && var4 < var2) {
  53.             if (this.sourceRegion == null || var3 < this.sourceRegion.width && var4 < this.sourceRegion.height) {
  54.                this.sourceXSubsampling = var1;
  55.                this.sourceYSubsampling = var2;
  56.                this.subsamplingXOffset = var3;
  57.                this.subsamplingYOffset = var4;
  58.             } else {
  59.                throw new IllegalStateException("region contains no pixels!");
  60.             }
  61.          } else {
  62.             throw new IllegalArgumentException("subsamplingYOffset out of range!");
  63.          }
  64.       } else {
  65.          throw new IllegalArgumentException("subsamplingXOffset out of range!");
  66.       }
  67.    }
  68.  
  69.    public int getSourceXSubsampling() {
  70.       return this.sourceXSubsampling;
  71.    }
  72.  
  73.    public int getSourceYSubsampling() {
  74.       return this.sourceYSubsampling;
  75.    }
  76.  
  77.    public int getSubsamplingXOffset() {
  78.       return this.subsamplingXOffset;
  79.    }
  80.  
  81.    public int getSubsamplingYOffset() {
  82.       return this.subsamplingYOffset;
  83.    }
  84.  
  85.    public void setSourceBands(int[] var1) {
  86.       if (var1 == null) {
  87.          this.sourceBands = null;
  88.       } else {
  89.          int var2 = var1.length;
  90.  
  91.          for(int var3 = 0; var3 < var2; ++var3) {
  92.             int var4 = var1[var3];
  93.             if (var4 < 0) {
  94.                throw new IllegalArgumentException("Band value < 0!");
  95.             }
  96.  
  97.             for(int var5 = var3 + 1; var5 < var2; ++var5) {
  98.                if (var4 == var1[var5]) {
  99.                   throw new IllegalArgumentException("Duplicate band value!");
  100.                }
  101.             }
  102.          }
  103.  
  104.          this.sourceBands = (int[])(([I)var1).clone();
  105.       }
  106.  
  107.    }
  108.  
  109.    public int[] getSourceBands() {
  110.       return this.sourceBands == null ? null : (int[])((int[])this.sourceBands.clone());
  111.    }
  112.  
  113.    public void setDestinationType(ImageTypeSpecifier var1) {
  114.       this.destinationType = var1;
  115.    }
  116.  
  117.    public ImageTypeSpecifier getDestinationType() {
  118.       return this.destinationType;
  119.    }
  120.  
  121.    public void setDestinationOffset(Point var1) {
  122.       if (var1 == null) {
  123.          throw new IllegalArgumentException("destinationOffset == null!");
  124.       } else {
  125.          this.destinationOffset = (Point)var1.clone();
  126.       }
  127.    }
  128.  
  129.    public Point getDestinationOffset() {
  130.       return (Point)this.destinationOffset.clone();
  131.    }
  132.  
  133.    public void setController(IIOParamController var1) {
  134.       this.controller = var1;
  135.    }
  136.  
  137.    public IIOParamController getController() {
  138.       return this.controller;
  139.    }
  140.  
  141.    public IIOParamController getDefaultController() {
  142.       return this.defaultController;
  143.    }
  144.  
  145.    public boolean hasController() {
  146.       return this.controller != null;
  147.    }
  148.  
  149.    public boolean activateController() {
  150.       if (!this.hasController()) {
  151.          throw new IllegalStateException("hasController() == false!");
  152.       } else {
  153.          return this.getController().activate(this);
  154.       }
  155.    }
  156. }
  157.